package com.chinaums.xm.wechat;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.context.request.async.DeferredResult;

import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
@EnableScheduling
@EnableSwagger2
@PropertySources({ @PropertySource(value = "classpath:application.properties"), })
public class WechatLauncher {

	public static void main(String[] args) {
		SpringApplication.run(WechatLauncher.class, args);
	}

	@Bean
	public Docket createRestApi() {
		return new Docket(DocumentationType.SWAGGER_2).groupName("stk").genericModelSubstitutes(DeferredResult.class)
				.apiInfo(ApiInfo()).useDefaultResponseMessages(false).forCodeGeneration(true).pathMapping("/").select()
				.paths(PathSelectors.regex("/wechat/.*")).build();
	}

	private ApiInfo ApiInfo() {
		final Contact contact = new Contact("陈俊飞", "", "chenjf@xmylsw.com");
		final ApiInfo apiInfo = new ApiInfo("微信接口", // 大标题
				"微信接口", // 小标题
				"0.1", // 版本
				"", contact, // 作者
				"", // 链接显示文字
				""// 网站链接
		);
		return apiInfo;
	}
}
